﻿
@{
    ViewBag.Title = "notice";
    Layout = "~/Views/Shared/Index.cshtml";
}
@model List<YaYun.Models.notice>

<h2>公告</h2>
<a href="/home/ADDnotice">发布公告</a>
<table class="layui-table layui-form">
    <tr>
        <th class="emp_id_td">序号</th>
        <th class="emp_tr_t">公告标题</th>
        <th class="emp_tr_t">公告内容</th>
        <th class="emp_tr_t">发布者</th>
        <th class="emp_tr_t">发布时间</th>
        <th class="emp_tr_t">操作</th>

    </tr>
    @{
        int numi = 1;
    }
    @foreach (var item in Model)
    {
        <tr class="tr_hover">
            <td class="emp_id_td">@numi</td>
            <td class="emp_tr_t">@item.title</td>
            <td class="emp_tr_t">@item.contentT</td>
            <td class="emp_tr_t">@item.notice_Name</td>
            <td class="emp_tr_t">@item.publish_time</td>
            <td class="emp_tr_t">
                <button type="button" onclick="DELnotice(@item.id,'@item.title')" class="layui-btn layui-btn-sm layui-btn-normal">
                    <i class="layui-icon layui-icon-delete"></i> 删除
                </button>
            </td>

        </tr>
        numi++;
    }

</table>


<div class="demo-laypage-pn-show">
    @Html.ActionLink("上一页", "notice", new { page = ViewBag.CurrentPage - 1 }, new { @class = "layui-btn" })
    @for (int i = 1; i <= ViewBag.TotalPages; i++)
    {
        if (i == ViewBag.CurrentPage)
        {
            @Html.Label($"{@i}", new { @class = "layui-btn layui-btn-sm layui-btn-warm" }) ;
        }
        else
        {
            @Html.ActionLink(i.ToString(), "notice", new { page = i }, new { @class = "layui-btn layui-btn-primary layui-btn-sm" });
        }
    }
    @Html.ActionLink("下一页", "notice", new { page = ViewBag.CurrentPage + 1 }, new { @class = "layui-btn" })
</div>

<script>
    function DELnotice(id,name) {
        if (confirm("确认要删除《"+name+"》公告吗？")) {
            window.location = ("/home/DELnotice?id=" + id);
        }
    }

</script>